﻿
@using System.Data;
@using Webdiyer.WebControls.Mvc;
@using Shop.Entity;
@{
    Layout = null;
}
@model  PagedList<DataRow>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>列表</title>
    <link href="~/Content/admin/css/bootstrap.min.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Content/My97DatePicker/WdatePicker.js"></script>
    <script src="~/Content/admin/js/bootstrap.min.js"></script>
    <script src="~/Content/MvcPager/MvcPager.js"></script>
    <style>
        .pibarea {
            float: left;
            margin-left: 2em;
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <ol class="breadcrumb">
            <li><a href="/set/admin/center">首页></a></li>
            <li><a href="#">资金结算></a></li>
            <li class="active">结算设置</li>
        </ol>

        <div class="portlet-body">
            <form class="navbar-form navbar-left" id="formSearch" role="form" action="/Settlement/StoreSet/List" style="padding:0 0;">
                查询:
                @Html.DropDownList("Business", ViewData["Business"] as IEnumerable<SelectListItem>, "-选择商户-", new { @class = "form-control input-sm" })
                <div class="form-group">
                    <input type="text" class="form-control input-sm" id="SearchTitle" name="storeName" placeholder="请输入门店名称" />
                </div>
                <button type="submit" class="btn btn-primary btn-sm ">
                    <span class="glyphicon glyphicon-search" aria-hidden="true"></span>&nbsp;搜索
                </button>

            </form>
            <div id="divTable">
                <table class="table table-bordered  table-condensed table-condensed  table-hover table-condensed">
                    <thead>
                        <tr>
                            <th>门店名称</th>
                            <th>所属商户</th>
                            <th>剩余短信</th>
                            <th>剩余积分</th>
                            <th>剩余余额</th>
                            <th>售卡提成</th>
                            <th>充值提成</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var row in Model)
                        {
                            <tr>
                                <td class="title">@row["Name"]</td>
                                <td>@row["BusinessName"]</td>
                                <td>100 条</td>
                                <td><strong>@row["AvailablePoint"]</strong>分</td>
                                <td><strong>@row["AvailableValue"]</strong>元</td>

                                <td><strong>100%</strong></td>
                                <td><strong>100%</strong></td>
                                <td>
                                    @*<a class="btn btn-default btn-xs" title='设置' onclick="Set('@row["Guid"]','@row["Name"]')">设置</a>*@


                                    @Ajax.ActionLink("设置", "Set", new { id = row["Guid"], name = row["name"] }, new AjaxOptions { OnSuccess = "Set", HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId = "Set" }, new { @class = "btn  btn-default btn-xs" })
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
                <div class="text-center">
                    <input type="hidden" value="@Model.TotalPageCount" id="TotalPageCount" />
                    <ul class="pagination">
                        <li>
                            <span aria-hidden="true">
                                @(Model.PageSize)条/页，@(Model.TotalPageCount)页, 共@(Model.TotalItemCount)条
                            </span>
                        </li>
                    </ul>
                    @Ajax.Pager(Model,
new PagerOptions
{
    PageIndexParameterName = "id",
    CssClass = "pagination",
    FirstPageText = "首页",
    LastPageText = "尾页",
    PrevPageText = "上一页",
    PageIndexBoxId = "pageIndexBox",
    NextPageText = "下一页",
    CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
    DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>",
    PagerItemTemplate = "<li>{0}</li>",
    AutoHide = false,

}, new MvcAjaxOptions
{
    UpdateTargetId = "divTable",
    HttpMethod = "Post",
    DataFormId = "formSearch",
    EnableHistorySupport = false,
    //OnSuccess = "EditMsg",
    EnablePartialLoading = true
}
)
                    <ul class="pagination">
                        <li>
                            <span aria-hidden="true" style="padding: 2px 3px;">
                                跳转到第<input id="pageIndexBox" class="form-control input-sm" style="width:auto;display:inline-block;border-radius:0;" oninput="InputPageIndex(this);" />
                                <button class="btn btn-primary btn-sm" style="border-radius:0px;" id="goBtn1" onclick="GoPageIndex();">Go</button>
                            </span>
                        </li>
                    </ul>
                </div>

                <script>
                    var txt = $("#SearchTitle").val().trim();
                    if (txt.length > 0)
                    {
                        $(".title").each(function ()
                        {
                            var newTxt = $(this).html().replace(txt, txt.fontcolor("red"));
                            $(this).html(newTxt);
                        });
                    }
                </script>
            </div>
            <div class="modal fade bs-example-modal-lg" id="Set" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                @Html.Partial("Set", new PagedList<DataRow>(new List<DataRow>(), 1, 1))
            </div>

        </div>
        @section Scripts{@{Html.RegisterMvcPagerScriptResource();}
        }

        <script src="/Content/Validform_v5.3.2/Validform_v5.3.2_min.js"></script>

        <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>

        <script src="http://markcell.github.io/jquery-tabledit/assets/js/tabledit.min.js"></script>
        <script type="text/javascript">
            function Set()
            {
                $('#Set').modal('show');
            }
            function InputPageIndex(obj)
            {
                var pageIndex = $(obj).val().trim();
                if (parseInt(pageIndex) > parseInt($("#TotalPageCount").val()))
                {
                    $(obj).val($("#TotalPageCount").val());
                }
            }
            function GoPageIndex()
            {
                var pager = Webdiyer.MvcPagers[0];
                var pageIndex = $("#pageIndexBox").val().trim();
                var TotalPageCount = $("#TotalPageCount").val().trim();
                if (parseInt(pageIndex) > parseInt(TotalPageCount))
                {
                    pageIndex = TotalPageCount;
                }
                if (pager != null)
                {
                    pager.goToPage(parseInt(pageIndex));
                } else
                { alert("找不到指定的MvcPager！"); }

            }
        </script>
    </div>
</body>
</html>
